package com.zc.custom.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.custom.domain.ChargeCustomOrderInfoProcess;
import com.zc.custom.service.IChargeCustomOrderInfoProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单流程Controller
 * 
 * @author glb
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/custom/process")
public class ChargeCustomOrderInfoProcessController extends BaseController
{
    @Autowired
    private IChargeCustomOrderInfoProcessService chargeCustomOrderInfoProcessService;

    /**
     * 查询订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('custom:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeCustomOrderInfoProcess chargeCustomOrderInfoProcess)
    {
        startPage();
        List<ChargeCustomOrderInfoProcess> list = chargeCustomOrderInfoProcessService.selectChargeCustomOrderInfoProcessList(chargeCustomOrderInfoProcess);
        return getDataTable(list);
    }

    /**
     * 导出订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('custom:process:export')")
    @Log(title = "订单流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeCustomOrderInfoProcess chargeCustomOrderInfoProcess)
    {
        List<ChargeCustomOrderInfoProcess> list = chargeCustomOrderInfoProcessService.selectChargeCustomOrderInfoProcessList(chargeCustomOrderInfoProcess);
        ExcelUtil<ChargeCustomOrderInfoProcess> util = new ExcelUtil<>(ChargeCustomOrderInfoProcess.class);
        util.exportExcel(response, list, "订单流程数据");
    }

    /**
     * 获取订单流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('custom:process:query')")
    @GetMapping(value = "/{orderInfoProcessId}")
    public AjaxResult getInfo(@PathVariable("orderInfoProcessId") Long orderInfoProcessId)
    {
        return AjaxResult.success(chargeCustomOrderInfoProcessService.selectChargeCustomOrderInfoProcessByOrderInfoProcessId(orderInfoProcessId));
    }

    /**
     * 新增订单流程
     */
    @PreAuthorize("@ss.hasPermi('custom:process:add')")
    @Log(title = "订单流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeCustomOrderInfoProcess chargeCustomOrderInfoProcess)
    {
        return toAjax(chargeCustomOrderInfoProcessService.insertChargeCustomOrderInfoProcess(chargeCustomOrderInfoProcess));
    }

    /**
     * 修改订单流程
     */
    @PreAuthorize("@ss.hasPermi('custom:process:edit')")
    @Log(title = "订单流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeCustomOrderInfoProcess chargeCustomOrderInfoProcess)
    {
        return toAjax(chargeCustomOrderInfoProcessService.updateChargeCustomOrderInfoProcess(chargeCustomOrderInfoProcess));
    }

    /**
     * 删除订单流程
     */
    @PreAuthorize("@ss.hasPermi('custom:process:remove')")
    @Log(title = "订单流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderInfoProcessIds}")
    public AjaxResult remove(@PathVariable Long[] orderInfoProcessIds)
    {
        return toAjax(chargeCustomOrderInfoProcessService.deleteChargeCustomOrderInfoProcessByOrderInfoProcessIds(orderInfoProcessIds));
    }
}
